import scrapy




class LatestPostSpider(scrapy.Spider):
    name = "latest_post"
    allowed_domains = ["www.x6g.com"]
    start_urls = ["https://www.x6g.com/"]


    def parse(self, response):
        elements = response.xpath('//li[@class="new"]')

        for element in elements:
            text = element.xpath('.//a[@target="_blank"]/text()').extract_first()
            url = element.xpath('.//a[@target="_blank"]/@href').extract_first()

            from new_daily_articles.new_daily_article.items import LatestPostItem
            item = LatestPostItem()

            item['text'] = text
            item['url'] = url
            yield item
